From 957baf211d21cf10ef0c796fbc422c38dfde2028 Mon Sep 17 00:00:00 2001
From: tsteven4 <13596209+tsteven4@users.noreply.github.com>
Date: Sun, 31 Jul 2022 11:59:34 -0600
Subject: [PATCH] return QString from html_entitize, xml_entitize. (#897)
---
defs.h | 4 ++--
html.cc | 27 ++++++++++-----------------
kml.cc | 6 ++----
osm.cc | 8 ++++----
util.cc | 12 +++++++-----
5 files changed, 25 insertions(+), 32 deletions(-)
diff --git a/defs.h b/defs.h
index e78886083..352c65a33 100644
--- a/defs.h
+++ b/defs.h
@@ -1079,8 +1079,8 @@ QDateTime dotnet_time_to_qdatetime(long long dotnet);
const char* get_cache_icon(const Waypoint* waypointp);
const char* gs_get_cachetype(geocache_type t);
const char* gs_get_container(geocache_container t);
-char* xml_entitize(const char* str);
-char* html_entitize(const QString& str);
+QString xml_entitize(const QString& str);
+QString html_entitize(const QString& str);
char* strip_html(const utf_string*);
char* strip_nastyhtml(const QString& in);
char* convert_human_date_format(const char* human_datef); /* "MM,YYYY,DD" -> "%m,%Y,%d" */
diff --git a/html.cc b/html.cc
index 8f3c07735..e84507f71 100644
--- a/html.cc
+++ b/html.cc
@@ -75,10 +75,9 @@ HtmlFormat::html_disp(const Waypoint* wpt) const
gbfprintf(file_out, "
\n");
if (wpt->description != wpt->shortname) {
if (wpt->HasUrlLink()) {
- char* d = html_entitize(wpt->description);
- UrlLink link = wpt->GetUrlLink();
- gbfprintf(file_out, "%s", CSTR(link.url_), d);
- xfree(d);
+ gbfputs(QStringLiteral("%2")
+ .arg(wpt->GetUrlLink().url_, html_entitize(wpt->description)),
+ file_out);
} else {
gbfprintf(file_out, "%s", CSTR(wpt->description));
}
@@ -139,9 +138,9 @@ HtmlFormat::html_disp(const Waypoint* wpt) const
logpart = xml_findfirst(curlog, "groundspeak:finder");
if (logpart) {
- char* f = html_entitize(logpart->cdata);
- gbfprintf(file_out, "%s on ", f);
- xfree(f);
+ gbfputs(QStringLiteral("%1 on ")
+ .arg(html_entitize(logpart->cdata)),
+ file_out);
}
logpart = xml_findfirst(curlog, "groundspeak:date");
@@ -178,9 +177,7 @@ HtmlFormat::html_disp(const Waypoint* wpt) const
s = logpart->cdata;
}
- char* t = html_entitize(s);
- gbfputs(t, file_out);
- xfree(t);
+ gbfputs(html_entitize(s), file_out);
}
gbfprintf(file_out, "